#!/bin/bash
RETVAL=0
export LANG=en
CHECK_DIR=$1

[ -e $CHECK_DIR ] || exit 1

zhiwen="/opt/zhiwen.db.ori"
wenjian="/opt/wenjian.db.ori"
newwenjian="/opt/wenjiannew.db.ori"
ErrLog="/opt/err.log"

[ -e $zhiwen ] || exit 1
[ -e $wenjian ] || exit 1

md5sum -c --quiet $zhiwen &> $ErrLog
RETVAL=$?

find $CHECK_DIR -type f > $newwenjian
diff $wenjian $newwenjian &>> $ErrLog
NUM=`diff $wenjian $newwenjian | wc -l`

if [ $RETVAL -ne 0 -o $NUM -ne 0 ] 
   then
      mail -s "`uname -n`$(date +%F) error" 363640619@qq.com < $ErrLog
else
  echo "website is ok" | mail -s "`uname -n`$(date +%F) is ok"  363640619@qq.com
fi


